const xss = require('xss');
const { exec, escape } = require('../db/mysql');
// const {genPassWord } = require('../utils/cryp')

const userLogin = (username, password) => {
    username = escape(username)
    
    // 生成加密密码
    // password = genPassword(password)
    password = escape(password)
    let sql = `select username,realname from users where username=${username} and password=${password}`;
    return exec(sql).then(rows => {
        return rows[0] || {};
    })
    // if(username === 'kruup'&& password == 123){
    //     return true
    // }
    // return false;
}

module.exports = {
    userLogin
}